package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class AddressCtr
{
    private AddressBook myPersons;
    private LoanContainer lc;
    
    
    /**
     * Constructor for the AddressCtr
     */
    public AddressCtr()
    {
        myPersons = AddressBook.getInstance();
        lc = LoanContainer.getInstance();
    }
    
    /**
     *  Get a person from the AddressBook
     *  @param id The persons id
     *  @return Person The object of a person
     */
    public Person getPerson(long id)
    {
        return myPersons.getPerson(id);
    }
    
    public void listPerson(long id)
    {
        myPersons.listPerson(id);
    }
    
    /**
     * Create a new person in AdressBook
     * @param id The persons id
     * @param name The name of the person
     * @param adress The persons adresse
     * @param The postal code of the adresse
     * @param city The name of the city
     * @param tlf The persons thelephone number
    */
    public void createPerson(long id, String name, String address, String postalCode, String city, String tlf)
    {   
        Person person = new Person(id, name, address, postalCode, city, tlf);
        myPersons.createPerson(person);
        
    }
    
    /**
     * Delete a person from the AddressBook
     * @param id The if of the person to delete
     */
    public void deletePerson(long id)
    {
        myPersons.deletePerson(id);
    }
    
    /**
     * Opdats the details of a person
     * @param id The persons id
     * @param name The name of the person
     * @param adress The persons adresse
     * @param The postal code of the adresse
     * @param city The name of the city
     * @param tlf The persons thelephone number
     */
    public void updatePerson(long id, String name, String address, String postalCode, String city, String tlf)
    {
        myPersons.setPerson(id, name, address, postalCode, city, tlf);
    }
    
    /**
     * Prints a list of all persons
     */
    public void listAllPersons()
    {
        myPersons.listPersons();
    }
}
